Implement Flask backend API with progress tracking endpoints - #80
Draft
moulongzhang with Copilot wants to merge 4 commits into
Draft
Implement Flask backend API with progress tracking endpoints#80moulongzhang with Copilot wants to merge 4 commits into
moulongzhang with Copilot wants to merge 4 commits into
Conversation
Co-authored-by: moulongzhang <39043782+moulongzhang@users.noreply.github.com>
Co-authored-by: moulongzhang <39043782+moulongzhang@users.noreply.github.com>
Co-authored-by: moulongzhang <39043782+moulongzhang@users.noreply.github.com>
Comment on lines
+81
to
+84
| return jsonify({ | ||
| "success": False, | ||
| "error": str(e) | ||
| }), 500 |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, we should avoid returning the actual exception message str(e) to the user in the JSON response. Instead, we should:
- Return a generic error message such as
"An internal error occurred!"or similar in the API response. This prevents leakage of exception details. - Optionally, to help with debugging, log the exception (including stack trace) on the server side using Python's
loggingmodule orprint(traceback.format_exc()). - The change is to the
exceptblock in thepost_progressroute, i.e., lines 81–83 of file main.py. - Additionally, import the
tracebackmodule (if logging a stack trace was chosen) and/or theloggingmodule. - If a logging solution is not already set up, use
print(traceback.format_exc())for simplicity.
Suggested changeset
1
main.py
| @@ -2,7 +2,7 @@ | ||
| import json | ||
| import os | ||
| import threading | ||
|
|
||
| import traceback | ||
| app = Flask(__name__) | ||
|
|
||
| # In-memory storage for progress data | ||
| @@ -78,9 +78,10 @@ | ||
| "data": data | ||
| }), 201 | ||
| except Exception as e: | ||
| print(traceback.format_exc()) | ||
| return jsonify({ | ||
| "success": False, | ||
| "error": str(e) | ||
| "error": "An internal error has occurred." | ||
| }), 500 | ||
|
|
||
| if __name__ == '__main__': |
Copilot is powered by AI and may make mistakes. Always verify output.
Copilot
AI
changed the title
[WIP] Implement backend API using Flask
Implement Flask backend API with progress tracking endpoints
Dec 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Step 3: Flask backend API with
/and/api/progressroutes for progress data management using hybrid in-memory/file storage.Implementation
Flask App (main.py)
/- API endpoint documentation/api/progressGET - Returns progress data array/api/progressPOST - Appends progress entry, persists toprogress.jsonthreading.Lock()for concurrent request handlingTests (test_main.py)
Dependencies
Example Usage
Security
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.